<template>
  <el-dialog title="" :visible.sync="dialogVisible" width="500px">
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="70px" class="demo-ruleForm">
      <el-form-item label="摘要：" prop="abstract">
        <el-input v-model="ruleForm.abstract" type="textarea" :rows="6" maxlength="500"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="submitForm('ruleForm')">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    name: "EditBanner",
    data(){
      return {
        dialogVisible: false,
        ruleForm: {
          abstract: '',
        },
        rules: {
          abstract: [
            { required: true, message: '请输入摘要', trigger: 'blur' },
          ],
        }
      }
    },
    props: ['info'],
    methods: {
      show(){
        this.dialogVisible = true
        const temp = JSON.parse(JSON.stringify(this.info))
        temp.summary = temp.summary.replace(/\<br\/\>/g,'\n')
        this.ruleForm.abstract = temp.summary
      },
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.$emit('success', this.ruleForm)
            this.dialogVisible = false
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }
    }
  }
</script>

<style scoped>

</style>
